<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的问卷</title>
      <link rel="stylesheet" href="../static/css/bootstrap.min.css">
        <link rel="stylesheet" href="../static/css/base.css">
        <link rel="stylesheet" href="../static/css/top.css">
</head>
<body>
  <div>
    <div>
      <nav class="navbar navbar-light" style="background-color: #e3f2fd;">
      
        <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
          <div class="navbar-nav" id="top">
            <ul>
              <li>
                <a class="nav-link" id="myQuestionair" onclick="home()">首页</a>
              </li>
              <li>
                <a class="nav-link" id="myQuestionair" onclick="my()
                ">我的问卷</a>
              </li>
           
              <li>
                <a class="nav-link" data-toggle="modal" data-target="#createQuestionair" onclick="home()">创建问卷</a>
              </li>
              <li>
                <a class="nav-link" onclick="logout()">注销</a>
              </li>
            </ul>
      
      
      
          </div>
        </div>
      </nav>
       <table class="table table-striped" style="text-align: center;">
        <thead>
          <tr>
            <td></td>
            <td scope="row">问卷主题</td>
            <td scope="row" >创建时间</td>
            <td scope="row" >发起人</td>
            <td scope="row">问卷操作</td>
            <td scope="row">分享链接</td>
          </tr>
        </thead>
        <tbody>
          {% for QS in currentUserQ %}
          <tr>
        
            <td scope="row"></td>
         
            <td>{{QS.topic}}</td> 
             <td>{{QS.createdTime}}</td>
            {% for U in findUser %}
            <td>{{U.username}}</td>
            {% endfor %}
          
            <td>
                <a  onclick="find('{{QS.id}}')">参与调查</a>
            </td>
            <td>
              <label for="">http://hcy.nrx0308.xyz/findPage/?id={{QS.id}}</label>
            </td>
          </tr>
              {% endfor %}
         
        </tbody>
      </table>

    </div>
  </div>
    <script src="../static/js/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="../static/js/bootstrap.min.js"></script>
    <script>

   //问卷调查
   var find = function(QSid){
     console.log(QSid);
    axios({
        method: 'post',
        url: '/questionairDome',
        data: {
          QSid
        }
      }).then(function (response) {
        var res = response.data;
        if (res.code === 200) {
          // 直接跳转到后端传出的/SQ1/?id=qsId路由
          window.location.href = res.url;
        }
      })
  
      }

   


      //跳转到首页

      function home()
      {
        window.location.href='/';
      }

       function my() {
          window.location.href = '/all';
        }
          //注销
            function logout() {
              axios({
                method: 'post',
                url: '/logout'
              }).then(function (response) {
                // axios工具下，服务器真正返回的数据在返回对象的data中
                let res = response.data;
                if (res.code === 200) {
                  window.location.href = '/user';
                }
              }).catch((err) => {

              });
            }

           
     
    </script>
</body>
</html>